package com.mak001.lite.multiSkill.subs;

import org.rsbuddy.tabs.Equipment;
import org.rsbuddy.tabs.Inventory;
import org.rsbuddy.widgets.Bank;

import com.mak001.lite.multiSkill.Methods;
import extras.mak001.Time;
import com.mak001.lite.multiSkill.subScript;
import com.rsbuddy.event.events.MessageEvent;
import com.rsbuddy.script.methods.Game;
import com.rsbuddy.script.methods.Skills;
import com.rsbuddy.script.methods.Widgets;
import com.rsbuddy.script.util.Timer;
import com.rsbuddy.script.wrappers.Component;

public class SuperHeaterLite extends subScript {
	int primary;
	int secondary;
	int withdraw;

	int fireRune = 554;
	int natureRune = 561;
	int staff = 1387;
	int numBars;
	String barName;

	@Override
	public void execute() {
			if (!Inventory.contains(primary)) {
				if (Bank.isOpen()) {
					if (Bank.getCount(primary) > 0) {
						Bank.withdraw(primary, withdraw);
						sleep(500);
						if (Bank.getCount(secondary) > 0) {
							Bank.withdraw(secondary, 0);
							sleep(500);
						} else {
							Methods.stopSub();
						}
					} else {
						Methods.stopSub();
					}
				} else {
					Bank.open();
				}
			} else {
				if (Bank.isOpen()) {
					Bank.close();
				} else {

					if (!Equipment.containsOneOf(staff)) {
						if (Inventory.getCount(natureRune) == 1) {
							if (Inventory.getCount(fireRune) < 4) {
								Methods.stopSub();
							}
						}
					} else if (Inventory.getCount(natureRune) == 0) {
						Methods.stopSub();
					}
					if (Game.getCurrentTab() != Game.TAB_MAGIC) {
						Game.openTab(Game.TAB_MAGIC);
					}
					Component c = Widgets.getComponent(192, 50);
					if (c != null) {
						for (int i = 0; i < 5; i++) {
							Timer to = new Timer(3000);
							c.click();
							while (to.isRunning()
									&& Game.getCurrentTab() != Game.TAB_INVENTORY) {
								sleep(100);
							}
							if (Game.getCurrentTab() == Game.TAB_INVENTORY) {
								if (Inventory.getItem(primary) != null) {
									if (Inventory.getItem(primary).click(true)) {
										numBars++;
										sleep(800);
									}
								}
							}
						}
					}
				}
			
		} 
	}

	@Override
	public int[] required() {
		int[] req;
		if (Equipment.containsOneOf(staff)) {
			int[] a = { natureRune };
			req = a;
		} else {
			int[] b = { fireRune, natureRune };
			req = b;
		}
		return req;
	}

	public void setInf(int p, int s, int w, String st) {
		this.primary = p;
		this.secondary = s;
		this.withdraw = w;
		this.barName = st;
	}

	@Override
	public boolean canSwitch() {
		return true;
	}

	@Override
	public String getStatus() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int skill() {
		return Skills.MAGIC;
	}

	@Override
	public void messageRecieved(MessageEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public String[] paintString() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Time getTime() {
		// TODO Auto-generated method stub
		return null;
	}

}
